#include<bits/stdc++.h>
using namespace std;
const int MAXN=1e4+10;
int n,m,f[MAXN],ans;
struct mouse
{
	int time,x,y;
}a[MAXN];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;++i)
	{
		scanf("%d%d%d",&a[i].time,&a[i].x,&a[i].y);
		f[i]=1;
		for(int j=1;j<i;++j)
			if(a[i].time-a[j].time>=abs(a[i].x-a[j].x)+abs(a[i].y-a[j].y)&&f[j]+1>f[i])
				f[i]=f[j]+1;
		ans=max(ans,f[i]);
	}
	printf("%d\n",ans);
	return 0;
}
